/*!
 * Copyright 2018 - 2024 Hitachi Vantara. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* globals requireCfg, packageInfo, getVersionedModuleId, SESSION_LOCALE, active_theme */

var basePath = packageInfo.webRootPath;
var sourcePath = basePath;
var useDebug = typeof document === "undefined" || document.location.href.indexOf("debug=true") > 0;

if(!useDebug) {
  basePath += "/compressed";
}

var requirePaths = requireCfg.paths;
var requireShim = requireCfg.shim;

// configure cdf's jquery-clean shim
// (not in package.json because functions aren't supported)
requireShim[getVersionedModuleId("common-ui/jquery-clean")] = {
  exports: "$",
  init: function() {
    return this.$.noConflict(true);
  }
};

// switch paths to use compressed versions
if(!useDebug) {
  [
    "common-ui",
    "common-repo",
    "common-data",

    "pentaho/common",

    "pentaho/_core",
    "pentaho/csrf",
    "pentaho/module",
    "pentaho/shim",
    "pentaho/util",
    "pentaho/lang",
    "pentaho/i18n",
    "pentaho/data",
    "pentaho/action",
    "pentaho/type",
    "pentaho/visual",
    "pentaho/config",
    "pentaho/environment",
    "pentaho/debug",
    "pentaho/ccc",
    "pentaho/platformCore",
    "pentaho/platformBundle",

    "local",
    "json",
    "text",
    "common-ui/util/require-css/css",

    "dojo",
    "dojox",
    "dijit",

    "dojo/on",
    "dojo/dom-geometry",
    "dojo/dom-prop",
    "dojox/layout/ResizeHandle",
    "dojox/grid/_View",
    "dojox/xml/parser",
    "dojox/grid/Selection",
    "dojox/grid/_FocusManager",
    "dojox/grid/_Scroller",
    "dojox/storage",
    "dojox/json",
    "dojox/rpc",
    "dojo/_base/kernel",
    "dojo/_base/config",
    "dojo/store/JsonRest",
    "dojo/store/Memory",
    "dijit/_HasDropDown",
    "dijit/_CssStateMixin",
    "dijit/_PaletteMixin",
    "dijit/Dialog",
    "dijit/Menu",
    "dojo/selector/_loader",
    "dojo/i18n",
    "dojo/request/default",

    "common-ui/jquery",
    "common-ui/jquery-clean",
    "common-ui/handlebars",
    "common-ui/jquery-i18n",
    "common-ui/jquery-pentaho-i18n",
    "common-ui/bootstrap",
    "common-ui/underscore"
  ].forEach(function(mid) {
    var versionMid = getVersionedModuleId(mid);
    var path = requirePaths[versionMid];
    var packagePath = path.substring(sourcePath.length);
    requirePaths[versionMid] = basePath + packagePath;
  });

  // Copied by hand from /target/requireCfg.bundles.js
  requireCfg.bundles["pentaho/platformCore"] = [
    "pentaho/util/has",
    "pentaho/util/object",
    "pentaho/util/fun",
    "pentaho/util/text",
    "pentaho/shim/_es6-promise/es6-promise",
    "pentaho/shim/es6-promise",
    "pentaho/util/requireJS",
    "pentaho/debug/Levels",
    "pentaho/debug/impl/Manager",
    "pentaho/util/domWindow",
    "pentaho/debug/manager",
    "pentaho/debug",
    "pentaho/lang/Base",
    "pentaho/lang/List",
    "pentaho/lang/SortedList",
    "pentaho/lang/ArgumentError",
    "pentaho/lang/ArgumentRequiredError",
    "pentaho/lang/ArgumentInvalidError",
    "pentaho/_core/module/MetaService",
    "pentaho/util/logger",
    "pentaho/util/arg",
    "pentaho/lang/ArgumentInvalidTypeError",
    "pentaho/lang/ArgumentRangeError",
    "pentaho/lang/OperationInvalidError",
    "pentaho/lang/NotImplementedError",
    "pentaho/util/error",
    "pentaho/util/promise",
    "pentaho/util/spec",
    "pentaho/module/util",
    "pentaho/_core/module/Meta",
    "pentaho/_core/module/InstanceMeta",
    "pentaho/_core/module/TypeMeta",
    "pentaho/_core/module/Service",
    "pentaho/module/Annotation",
    "pentaho/_core/config/Service",
    "pentaho/config/ExternalAnnotation",
    "pentaho/_core/Core",
    "pentaho/util/url",
    "pentaho/environment/impl/Environment",
    "pentaho/environment/main",
    "pentaho/environment",
    "pentaho/_core/main",
    "pentaho/config/service",
    "pentaho/config/impl/Service",
    "pentaho/module/service",
    "pentaho/module/metaService",
    "pentaho/module/metaOf",
    "pentaho/module",
    "pentaho/module/impl/ServicePlugin",
    "pentaho/module/subtypeOf",
    "pentaho/module/subtypesOf",
    "pentaho/module/instanceOf",
    "pentaho/module/instancesOf",
    "pentaho/i18n/MessageBundle",
    "pentaho/i18n/LoadConfigAnnotation",
    "pentaho/theme/main",
    "pentaho/theme",
    "pentaho/theme/ThemeAnnotation",
    "pentaho/theme/impl/Service",
    "pentaho/theme/service",
    "pentaho/theme/LoadThemeAnnotation",
    "pentaho/csrf/service",
    "pentaho/lang/UserError",
    "pentaho/lang/RuntimeError",
    "pentaho/lang/Event",
    "pentaho/lang/EventSource",
    "pentaho/lang/Collection",
    "pentaho/util/date"
  ];

  requireCfg.bundles["pentaho/platformBundle"] = [
    "pentaho/type/SpecificationContext",
    "pentaho/type/SpecificationScope",
    "pentaho/type/impl/SpecificationProcessor",
    "pentaho/type/impl/Loader",
    "pentaho/type/_baseLoader",
    "pentaho/type/InstanceType",
    "pentaho/type/Instance",
    "pentaho/action/States",
    "pentaho/action/Execution",
    "pentaho/type/action/_transactionControl",
    "pentaho/type/ReferenceList",
    "pentaho/type/action/ChangeRef",
    "pentaho/type/action/AbstractTransactionScope",
    "pentaho/type/action/TransactionScope",
    "pentaho/type/action/CommittedScope",
    "pentaho/type/action/TransactionRejectedError",
    "pentaho/type/action/Transaction",
    "pentaho/type/util",
    "pentaho/type/ValidationError",
    "pentaho/type/Value",
    "pentaho/type/Element",
    "pentaho/type/mixins/Container",
    "pentaho/action/Base",
    "pentaho/type/action/Change",
    "pentaho/type/action/Changeset",
    "pentaho/type/action/PrimitiveChange",
    "pentaho/type/action/Add",
    "pentaho/type/action/Remove",
    "pentaho/type/action/Move",
    "pentaho/type/action/Sort",
    "pentaho/type/action/Clear",
    "pentaho/type/action/ListChangeset",
    "pentaho/type/List",
    "pentaho/type/mixins/DiscreteDomain",
    "pentaho/type/Property",
    "pentaho/type/PropertyTypeCollection",
    "pentaho/type/action/Replace",
    "pentaho/type/action/ComplexChangeset",
    "pentaho/type/Simple",
    "pentaho/type/String",
    "pentaho/type/Number",
    "pentaho/type/Boolean",
    "pentaho/type/Date",
    "pentaho/type/Object",
    "pentaho/type/Function",
    "pentaho/type/TypeDescriptor",
    "pentaho/type/standardSimple",
    "pentaho/type/Complex",
    "pentaho/type/mixins/Enum",
    "pentaho/type/standard",
    "pentaho/type/loader",
    "pentaho/data/_ElementMock",
    "pentaho/data/AtomicTypeName",
    "pentaho/data/_AbstractTable",
    "pentaho/data/_OfAttribute",
    "pentaho/lang/_Annotatable",
    "pentaho/data/Member",
    "pentaho/data/Cell",
    "pentaho/data/StructurePosition",
    "pentaho/data/MemberCollection",
    "pentaho/data/Attribute",
    "pentaho/data/AttributeCollection",
    "pentaho/data/Model",
    "pentaho/data/Structure",
    "pentaho/data/_plain/Row",
    "pentaho/data/_WithStructure",
    "pentaho/data/CellTuple",
    "pentaho/data/_WithCellTupleBase",
    "pentaho/data/_plain/RowList",
    "pentaho/data/_plain/Table",
    "pentaho/data/_cross/AxisPosition",
    "pentaho/data/_cross/Axis",
    "pentaho/data/_cross/MeasureCellSet",
    "pentaho/data/_cross/Table",
    "pentaho/data/_Table",
    "pentaho/data/_TableView",
    "pentaho/data/AbstractTable",
    "pentaho/data/Table",
    "pentaho/data/TableView",
    "pentaho/data/filter/_core/Tree",
    "pentaho/data/filter/KnownFilterKind",
    "pentaho/data/filter/_core/And",
    "pentaho/data/filter/_core/Or",
    "pentaho/data/filter/_core/Not",
    "pentaho/data/filter/_core/True",
    "pentaho/data/filter/_core/False",
    "pentaho/data/filter/_core/Property",
    "pentaho/data/filter/_core/IsEqual",
    "pentaho/data/filter/_core/IsIn",
    "pentaho/data/filter/_core/IsGreater",
    "pentaho/data/filter/_core/IsLess",
    "pentaho/data/filter/_core/IsGreaterOrEqual",
    "pentaho/data/filter/_core/IsLessOrEqual",
    "pentaho/data/filter/_core/IsLike",
    "pentaho/data/filter/Abstract",
    "pentaho/data/filter/Tree",
    "pentaho/data/filter/Property",
    "pentaho/data/filter/And",
    "pentaho/data/filter/Or",
    "pentaho/data/filter/Not",
    "pentaho/data/filter/IsEqual",
    "pentaho/data/filter/IsIn",
    "pentaho/data/filter/IsGreater",
    "pentaho/data/filter/IsLess",
    "pentaho/data/filter/IsGreaterOrEqual",
    "pentaho/data/filter/IsLessOrEqual",
    "pentaho/data/filter/IsLike",
    "pentaho/data/filter/True",
    "pentaho/data/filter/False",
    "pentaho/data/filter/standard",
    "pentaho/visual/role/MappingField",
    "pentaho/data/util",
    "pentaho/visual/role/AbstractMapping",
    "pentaho/visual/KeyTypes",
    "pentaho/visual/role/AbstractProperty",
    "pentaho/visual/color/Level",
    "pentaho/visual/color/Palette",
    "pentaho/visual/color/PaletteProperty",
    "pentaho/visual/Application",
    "pentaho/visual/AbstractModel",
    "pentaho/action/impl/Target",
    "pentaho/action/Generic",
    "pentaho/visual/action/Base",
    "pentaho/visual/action/Update",
    "pentaho/visual/action/ModelChangedError",
    "pentaho/visual/action/UpdateExecution",
    "pentaho/visual/action/Interaction",
    "pentaho/visual/action/InteractionExecution",
    "pentaho/visual/action/mixins/Data",
    "pentaho/visual/action/mixins/Positioned",
    "pentaho/visual/action/SelectionModes",
    "pentaho/visual/action/Select",
    "pentaho/visual/action/SelectExecution",
    "pentaho/visual/action/Execute",
    "pentaho/visual/action/Message",
    "pentaho/visual/role/Mode",
    "pentaho/visual/role/Mapping",
    "pentaho/visual/role/Property",
    "pentaho/visual/Model",
    "pentaho/util/BitSet",
    "pentaho/visual/impl/View",
    "pentaho/visual/role/ExternalMapping",
    "pentaho/visual/role/ExternalProperty",
    "pentaho/visual/ModelAdapter",
    "pentaho/visual/action/WellKnownErrorNames",
    "pentaho/visual/color/util",
    "pentaho/visual/color/palettes/divergentRyb3",
    "pentaho/visual/color/palettes/divergentRyb5",
    "pentaho/visual/color/palettes/divergentRyg3",
    "pentaho/visual/color/palettes/divergentRyg5",
    "pentaho/visual/color/palettes/nominalDark",
    "pentaho/visual/color/palettes/nominalLight",
    "pentaho/visual/color/palettes/nominalNeutral",
    "pentaho/visual/color/palettes/nominalPrimary",
    "pentaho/visual/color/palettes/quantitativeBlue3",
    "pentaho/visual/color/palettes/quantitativeBlue5",
    "pentaho/visual/color/palettes/quantitativeGray3",
    "pentaho/visual/color/palettes/quantitativeGray5",
    "pentaho/visual/color/palettes/all",
    "pentaho/visual/models/types/Color",
    "pentaho/visual/models/types/BackgroundFill",
    "pentaho/visual/models/types/FontStyle",
    "pentaho/visual/models/types/Sides",
    "pentaho/visual/models/types/LabelsOption",
    "pentaho/visual/models/Abstract",
    "pentaho/visual/models/types/DisplayUnits",
    "pentaho/visual/models/CartesianAbstract",
    "pentaho/visual/models/mixins/ScaleColorDiscrete",
    "pentaho/visual/models/CategoricalContinuousAbstract",
    "pentaho/visual/models/types/MaxChartsPerRow",
    "pentaho/visual/models/types/MultiChartRangeScope",
    "pentaho/visual/models/types/MultiChartOverflow",
    "pentaho/visual/models/types/MultiChartMax",
    "pentaho/visual/models/mixins/MultiCharted",
    "pentaho/visual/models/types/EmptyCellMode",
    "pentaho/visual/models/mixins/Interpolated",
    "pentaho/visual/models/PointAbstract",
    "pentaho/visual/models/AreaStacked",
    "pentaho/visual/models/BarAbstract",
    "pentaho/visual/models/types/TrendType",
    "pentaho/visual/models/types/LineWidth",
    "pentaho/visual/models/mixins/Trended",
    "pentaho/visual/models/Bar",
    "pentaho/visual/models/BarHorizontal",
    "pentaho/visual/models/types/Shape",
    "pentaho/visual/models/BarLine",
    "pentaho/visual/models/BarNormalizedAbstract",
    "pentaho/visual/models/BarNormalized",
    "pentaho/visual/models/BarNormalizedHorizontal",
    "pentaho/visual/models/BarStacked",
    "pentaho/visual/models/BarStackedHorizontal",
    "pentaho/visual/models/types/ColorSet",
    "pentaho/visual/models/types/Pattern",
    "pentaho/visual/models/mixins/ScaleColorContinuous",
    "pentaho/visual/models/MetricPointAbstract",
    "pentaho/visual/models/types/SizeByNegativesMode",
    "pentaho/visual/models/mixins/ScaleSizeContinuous",
    "pentaho/visual/models/Bubble",
    "pentaho/visual/models/Boxplot",
    "pentaho/visual/models/Dot",
    "pentaho/visual/models/Pie",
    "pentaho/visual/models/Donut",
    "pentaho/visual/models/types/SliceOrder",
    "pentaho/visual/models/Funnel",
    "pentaho/visual/models/Gauge",
    "pentaho/visual/models/HeatGrid",
    "pentaho/visual/models/LineAbstract",
    "pentaho/visual/models/Line",
    "pentaho/visual/models/LineStacked",
    "pentaho/visual/models/types/RadarShape",
    "pentaho/visual/models/Radar",
    "pentaho/visual/models/Scatter",
    "pentaho/visual/models/Sunburst",
    "pentaho/visual/models/types/TreemapLayoutMode",
    "pentaho/visual/models/Treemap",
    "pentaho/visual/models/types/WaterDirection",
    "pentaho/visual/models/Waterfall",
    "pentaho/visual/models/all",
    "pentaho/visual/role/adaptation/Strategy",
    "pentaho/visual/role/adaptation/IdentityStrategy",
    "pentaho/visual/role/adaptation/TupleStrategy",
    "pentaho/visual/role/adaptation/CombineStrategy",
    "pentaho/visual/role/adaptation/TimeIntervalDuration",
    "pentaho/visual/role/adaptation/EntityWithTimeIntervalKeyStrategy",
    "pentaho/visual/role/adaptation/EntityWithNumberKeyStrategy",
    "pentaho/visual/role/adaptation/allStrategies",
    "pentaho/visual/role/util",
    "pentaho/visual/scene/util",
    "pentaho/visual/scene/impl/Variable",
    "pentaho/visual/scene/Base",
    "pentaho/visual/DefaultViewAnnotation",
    "pentaho/visual/util",
    "pentaho/visual/samples/calc/Model",
    "pentaho/ccc/visual/_util",
    "pentaho/ccc/visual/Abstract",
    "pentaho/ccc/visual/CartesianAbstract",
    "pentaho/ccc/visual/CategoricalContinuousAbstract",
    "pentaho/ccc/visual/PointAbstract",
    "pentaho/ccc/visual/AreaAbstract",
    "pentaho/ccc/visual/Area",
    "pentaho/ccc/visual/AreaStacked",
    "pentaho/ccc/visual/BarAbstract",
    "pentaho/data/_trends",
    "pentaho/data/_trend-linear",
    "pentaho/data/trends",
    "pentaho/ccc/visual/_trends",
    "pentaho/ccc/visual/Bar",
    "pentaho/ccc/visual/BarHorizontal",
    "pentaho/ccc/visual/BarLine",
    "pentaho/ccc/visual/BarNormalizedAbstract",
    "pentaho/ccc/visual/BarNormalized",
    "pentaho/ccc/visual/BarNormalizedHorizontal",
    "pentaho/ccc/visual/BarStacked",
    "pentaho/ccc/visual/BarStackedHorizontal",
    "pentaho/ccc/visual/Boxplot",
    "pentaho/ccc/visual/MetricPointAbstract",
    "pentaho/ccc/visual/Bubble",
    "pentaho/ccc/visual/Dot",
    "pentaho/ccc/visual/Pie",
    "pentaho/ccc/visual/Donut",
    "pentaho/ccc/visual/HeatGrid",
    "pentaho/ccc/visual/LineAbstract",
    "pentaho/ccc/visual/Line",
    "pentaho/ccc/visual/LineStacked",
    "pentaho/ccc/visual/Scatter",
    "pentaho/ccc/visual/Sunburst",
    "pentaho/ccc/visual/Treemap",
    "pentaho/ccc/visual/Waterfall",
    "pentaho/ccc/visual/all",
    "pentaho/visual/views/echarts/Abstract",
    "pentaho/visual/views/echarts/Funnel",
    "pentaho/visual/views/echarts/Gauge",
    "pentaho/visual/views/echarts/Radar",
    "pentaho/visual/views/all"
  ];
}
